

import React from 'react'
import merge from 'lodash/merge'

import { Modal, message } from 'antd'


export const MessageContextHolder = () => {
    const [messageApi, contextHolder] = message.useMessage({
      // top: 84
    })
  
    React.$message = messageApi
  
    return contextHolder
  }

export const ModalContextHolder = () => {
    const [modal, contextHolder] = Modal.useModal()
  
    React.$modal = modal
  
    React.$confirm = (config = {}) => {
      return modal.confirm(
        merge(
          {
            title: '提示',
            width: 500,
            icon: React.$icon('icon-ic_prompt_1', 'anticon'),
            autoFocusButton: null,
            centered: true
          },
          config
        )
      )
    }
  
    return contextHolder
  }
  